<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta name="baidu-site-verification" content="bk1wz1wzS4">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">



<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css">


  <meta name="keywords" content="总结,">








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0">






<meta name="description" content="ion-nav-view加载ion-nav-view标签可以用来导航页面，并可以制作导航时候的页面动画，建议页面过渡的动作：’slide-left-right’,’slide-left-right-ios7’,’slide-in-up’。12&amp;lt;ion-nav-view animation=&quot;slide-left-right&quot;&amp;gt;&amp;lt;/ion-nav-view&amp;gt; 利用$state">
<meta name="keywords" content="总结">
<meta property="og:type" content="article">
<meta property="og:title" content="ionic总结一">
<meta property="og:url" content="https://youandme66.github.io/2016/12/25/first/index.html">
<meta property="og:site_name" content="腊月的季节">
<meta property="og:description" content="ion-nav-view加载ion-nav-view标签可以用来导航页面，并可以制作导航时候的页面动画，建议页面过渡的动作：’slide-left-right’,’slide-left-right-ios7’,’slide-in-up’。12&amp;lt;ion-nav-view animation=&quot;slide-left-right&quot;&amp;gt;&amp;lt;/ion-nav-view&amp;gt; 利用$state">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-01-18T06:18:02.374Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ionic总结一">
<meta name="twitter:description" content="ion-nav-view加载ion-nav-view标签可以用来导航页面，并可以制作导航时候的页面动画，建议页面过渡的动作：’slide-left-right’,’slide-left-right-ios7’,’slide-in-up’。12&amp;lt;ion-nav-view animation=&quot;slide-left-right&quot;&amp;gt;&amp;lt;/ion-nav-view&amp;gt; 利用$state">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: 'youandme'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://youandme66.github.io/2016/12/25/first/">





  <title> ionic总结一 | 腊月的季节 </title>
  <script>
  (function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
  })();
</script>
</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">腊月的季节</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope="" itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="https://youandme66.github.io/2016/12/25/first/">

  <span style="display:none" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
    <meta itemprop="name" content="腊月的季节">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/uploads/avatar.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="腊月的季节">
    <span style="display:none" itemprop="logo" itemscope="" itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="腊月的季节" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                ionic总结一
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2016-12-25T00:00:00+08:00">
                2016-12-25
              </time>
            

            

            
          </span>

          
            <span class="post-category">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/categories/html/" itemprop="url" rel="index">
                    <span itemprop="name">html</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/categories/html/ionic/" itemprop="url" rel="index">
                    <span itemprop="name">ionic</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
            <!--noindex-->
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                  <a href="/2016/12/25/first/#comments" itemprop="discussionUrl">
                    <span class="post-comments-count hc-comment-count" data-xid="2016/12/25/first/" itemprop="commentsCount"></span>
                  </a>
                </span>
              </span>
              <!--/noindex-->
            
          

          

          
          
             <span id="/2016/12/25/first/" class="leancloud_visitors" data-flag-title="ionic总结一">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="ion-nav-view加载"><a href="#ion-nav-view加载" class="headerlink" title="ion-nav-view加载"></a>ion-nav-view加载</h3><p>ion-nav-view标签可以用来导航页面，并可以制作导航时候的页面动画，建议页面过渡的动作：’slide-left-right’,’slide-left-right-ios7’,’slide-in-up’。<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ion-nav-view</span> <span class="attr">animation</span>=<span class="string">"slide-left-right"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-nav-view</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>利用$stateProvider进行渲染<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> app = angular.module(<span class="string">'myApp'</span>, [<span class="string">'ionic'</span>]);</span><br><span class="line">app.config(<span class="function"><span class="keyword">function</span>(<span class="params">$stateProvider</span>) </span>&#123;</span><br><span class="line">  $stateProvider</span><br><span class="line">  .state(<span class="string">'index'</span>, &#123;</span><br><span class="line">    url: <span class="string">'/'</span>,</span><br><span class="line">    templateUrl: <span class="string">'home.html'</span></span><br><span class="line">  &#125;)</span><br><span class="line">  .state(<span class="string">'music'</span>, &#123;</span><br><span class="line">    url: <span class="string">'/music'</span>,</span><br><span class="line">    templateUrl: <span class="string">'music.html'</span></span><br><span class="line">  &#125;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>
<p>在app启动时$stateProvider就会检查url，检查它的索引匹配状态，然后把home.html加载到<ion-nav-view>内，页面由指定的URL加载。</ion-nav-view></p>
<h3 id="ion-header-bar添加一个header栏"><a href="#ion-header-bar添加一个header栏" class="headerlink" title="ion-header-bar添加一个header栏"></a>ion-header-bar添加一个header栏</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ion-header-bar</span> <span class="attr">align-title</span>=<span class="string">"left"</span> <span class="attr">class</span>=<span class="string">"bar-positive"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"buttons"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"button"</span> <span class="attr">ng-click</span>=<span class="string">"doSomething()"</span>&gt;</span>左侧按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">h1</span> <span class="attr">class</span>=<span class="string">"title"</span>&gt;</span>Title!<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"buttons"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"button"</span>&gt;</span>右侧按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-header-bar</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">ion-content</span>&gt;</span></span><br><span class="line">  一些内容!</span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-content</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>align-title属性：标题对齐的位置，值可为”left”,”right”,或者”center”.默认为”center”。</p>
<h3 id="ion-footbar-bar添加页脚"><a href="#ion-footbar-bar添加页脚" class="headerlink" title="ion-footbar-bar添加页脚"></a>ion-footbar-bar添加页脚</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ion-content</span>&gt;</span></span><br><span class="line">  一些内容!</span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-content</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">ion-footer-bar</span> <span class="attr">align-title</span>=<span class="string">"left"</span> <span class="attr">class</span>=<span class="string">"bar-assertive"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"buttons"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"button"</span>&gt;</span>左侧按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">h1</span> <span class="attr">class</span>=<span class="string">"title"</span>&gt;</span>Title!<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"buttons"</span> <span class="attr">ng-click</span>=<span class="string">"doSomething()"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"button"</span>&gt;</span>右侧按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-footer-bar</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>align-title同上</p>
<h3 id="选项卡"><a href="#选项卡" class="headerlink" title="选项卡"></a><ion-tabs><ion-tab>选项卡</ion-tab></ion-tabs></h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ion-tabs</span> <span class="attr">class</span>=<span class="string">"tabs-positive tabs-icon-only"</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-tab</span> <span class="attr">title</span>=<span class="string">"首页"</span> <span class="attr">icon-on</span>=<span class="string">"ion-ios7-filing"</span> <span class="attr">icon-off</span>=<span class="string">"ion-ios7-filing-outline"</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 标签 1 内容 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-tab</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-tab</span> <span class="attr">title</span>=<span class="string">"关于"</span> <span class="attr">icon-on</span>=<span class="string">"ion-ios7-clock"</span> <span class="attr">icon-off</span>=<span class="string">"ion-ios7-clock-outline"</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 标签 2 内容 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-tab</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-tab</span> <span class="attr">title</span>=<span class="string">"设置"</span> <span class="attr">icon-on</span>=<span class="string">"ion-ios7-gear"</span> <span class="attr">icon-off</span>=<span class="string">"ion-ios7-gear-outline"</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 标签 3 内容 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-tab</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-tabs</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="侧栏菜单"><a href="#侧栏菜单" class="headerlink" title="侧栏菜单"></a>侧栏菜单</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ion-side-menus</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 中间内容 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-side-menu-content</span> <span class="attr">ng-controller</span>=<span class="string">"ContentController"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-side-menu-content</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">&lt;!-- 左侧菜单 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-side-menu</span> <span class="attr">side</span>=<span class="string">"left"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-side-menu</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">&lt;!-- 右侧菜单 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">ion-side-menu</span> <span class="attr">side</span>=<span class="string">"right"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">ion-side-menu</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ion-side-menus</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">ContentController</span>(<span class="params">$scope, $ionicSideMenuDelegate</span>) </span>&#123;</span><br><span class="line">  $scope.toggleLeft = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    $ionicSideMenuDelegate.toggleLeft();</span><br><span class="line">  &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>delegate-handle属性，该句柄用来标识带有$ionicSideMenuDelegate的侧栏菜单<br>侧栏菜单分三部分中间内容，左侧栏，右侧栏，控制侧栏出现和隐藏应该在中间内容中。外面被<ion-side-menus>包裹。中间内容由<ion-side-menu-content>包裹，侧栏由<ion-side-menu>包裹，side属性控制左右。$ionicSideMenuDelegate.toggleLeft()服务控制侧栏显示隐藏。menu-toggle属性打开指定侧栏菜单,menu-close属性关闭当前打开的侧栏菜单。</ion-side-menu></ion-side-menu-content></ion-side-menus></p>
<h3 id="弹出窗口"><a href="#弹出窗口" class="headerlink" title="弹出窗口"></a>弹出窗口</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line">angular.module(<span class="string">'mySuperApp'</span>, [<span class="string">'ionic'</span>])</span><br><span class="line">.controller(<span class="function"><span class="keyword">function</span>(<span class="params">$scope, $ionicPopup, $timeout</span>) </span>&#123;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 触发一个按钮点击，或一些其他目标</span></span><br><span class="line"> $scope.showPopup = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">   $scope.data = &#123;&#125;</span><br><span class="line"></span><br><span class="line">   <span class="comment">// 一个精心制作的自定义弹窗</span></span><br><span class="line">   <span class="keyword">var</span> myPopup = $ionicPopup.show(&#123;</span><br><span class="line">     template: <span class="string">'&lt;input type="password" ng-model="data.wifi"&gt;'</span>,</span><br><span class="line">     title: <span class="string">'Enter Wi-Fi Password'</span>,</span><br><span class="line">     subTitle: <span class="string">'Please use normal things'</span>,</span><br><span class="line">     scope: $scope,</span><br><span class="line">     buttons: [</span><br><span class="line">       &#123; <span class="attr">text</span>: <span class="string">'Cancel'</span> &#125;,</span><br><span class="line">       &#123;</span><br><span class="line">         text: <span class="string">'&lt;b&gt;Save&lt;/b&gt;'</span>,</span><br><span class="line">         type: <span class="string">'button-positive'</span>,</span><br><span class="line">         onTap: <span class="function"><span class="keyword">function</span>(<span class="params">e</span>) </span>&#123;</span><br><span class="line">           <span class="keyword">if</span> (!$scope.data.wifi) &#123;</span><br><span class="line">             <span class="comment">//不允许用户关闭，除非他键入wifi密码</span></span><br><span class="line">             e.preventDefault();</span><br><span class="line">           &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">             <span class="keyword">return</span> $scope.data.wifi;</span><br><span class="line">           &#125;</span><br><span class="line">         &#125;</span><br><span class="line">       &#125;,</span><br><span class="line">     ]</span><br><span class="line">   &#125;);</span><br><span class="line">   myPopup.then(<span class="function"><span class="keyword">function</span>(<span class="params">res</span>) </span>&#123;</span><br><span class="line">     <span class="built_in">console</span>.log(<span class="string">'Tapped!'</span>, res);</span><br><span class="line">   &#125;);</span><br><span class="line">   $timeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">      myPopup.close(); <span class="comment">//由于某种原因3秒后关闭弹出</span></span><br><span class="line">   &#125;, <span class="number">3000</span>);</span><br><span class="line"></span><br><span class="line">   <span class="comment">// 一个确认对话框</span></span><br><span class="line">   $scope.showConfirm = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">     <span class="keyword">var</span> confirmPopup = $ionicPopup.confirm(&#123;</span><br><span class="line">       title: <span class="string">'Consume Ice Cream'</span>,</span><br><span class="line">       template: <span class="string">'Are you sure you want to eat this ice cream?'</span></span><br><span class="line">     &#125;);</span><br><span class="line">     confirmPopup.then(<span class="function"><span class="keyword">function</span>(<span class="params">res</span>) </span>&#123;</span><br><span class="line">       <span class="keyword">if</span>(res) &#123;</span><br><span class="line">         <span class="built_in">console</span>.log(<span class="string">'You are sure'</span>);</span><br><span class="line">       &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">         <span class="built_in">console</span>.log(<span class="string">'You are not sure'</span>);</span><br><span class="line">       &#125;</span><br><span class="line">     &#125;);</span><br><span class="line">   &#125;;</span><br><span class="line"></span><br><span class="line">   <span class="comment">// 一个提示对话框</span></span><br><span class="line">   $scope.showAlert = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">     <span class="keyword">var</span> alertPopup = $ionicPopup.alert(&#123;</span><br><span class="line">       title: <span class="string">'Don\'t eat that!'</span>,</span><br><span class="line">       template: <span class="string">'It might taste good'</span></span><br><span class="line">     &#125;);</span><br><span class="line">     alertPopup.then(<span class="function"><span class="keyword">function</span>(<span class="params">res</span>) </span>&#123;</span><br><span class="line">       <span class="built_in">console</span>.log(<span class="string">'Thank you for not eating my delicious ice cream cone'</span>);</span><br><span class="line">     &#125;);</span><br><span class="line">   &#125;;</span><br><span class="line"> &#125;;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<p>show(可选)<br>显示一个复杂的对话框。<br>一个带有按钮组的复杂弹窗，每个按钮带有一个文本 和 类型字段，此外还有一个 onTap功能。当点击弹窗上的相关按钮，会触发onTap函数，默认会关闭弹窗，处理弹窗的返回值。如果你想阻止默认动作，点击按钮保持打开弹窗，当点击一个事件时，触发event.preventDefault()。<br>详见如下表格。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>
<td>object</td>
<td>新弹窗的选项的表现形式见下</td>
</tr>
</tbody>
</table>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  title: '', // String. 弹窗的标题。</span><br><span class="line">  subTitle: '', // String (可选)。弹窗的子标题。</span><br><span class="line">  template: '', // String (可选)。放在弹窗body内的html模板。</span><br><span class="line">  templateUrl: '', // String (可选)。在弹窗body内的html模板的URL。</span><br><span class="line">  scope: null, // Scope (可选)。一个链接到弹窗内容的scope（作用域）。</span><br><span class="line">  buttons: [&#123; //Array[Object] (可选)。放在弹窗footer内的按钮。</span><br><span class="line">    text: 'Cancel',</span><br><span class="line">    type: 'button-default',</span><br><span class="line">    onTap: function(e) &#123;</span><br><span class="line">      // 当点击时，e.preventDefault() 会阻止弹窗关闭。</span><br><span class="line">      e.preventDefault();</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;, &#123;</span><br><span class="line">    text: 'OK',</span><br><span class="line">    type: 'button-positive',</span><br><span class="line">    onTap: function(e) &#123;</span><br><span class="line">      // 返回的值会导致处理给定的值。</span><br><span class="line">      return scope.data.response;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>返回: object 当关闭弹窗时，处理一个promise。有一个附加的关闭函数，用于利用程序关闭弹窗。<br>alert(可选)<br>显示一个带有一段信息和一个用户可以点击关闭弹窗的按钮的简单提示弹窗。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>
<td>object</td>
<td>显示提示的选项形式见下</td>
</tr>
</tbody>
</table>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  title: '', // String. 弹窗的标题。</span><br><span class="line">  subTitle: '', // String (可选)。弹窗的子标题。</span><br><span class="line">  template: '', // String (可选)。放在弹窗body内的html模板。</span><br><span class="line">  templateUrl: '', // String (可选)。 放在弹窗body内的html模板的URL。</span><br><span class="line">  okText: '', // String (默认: 'OK')。OK按钮的文字。</span><br><span class="line">  okType: '', // String (默认: 'button-positive')。OK按钮的类型。</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>返回: object 当弹窗关闭时，处理的一个 promise。有一个额外的关闭函数，可以被带有任何给定的值的关闭程序调用。<br>confirm(可选)<br>显示一个简单的带有一个取消和OK按钮的对话框弹窗。</p>
<p>如果用户点击OK按钮，就设置promise为true，如果用户点击取消按钮则为false。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>
<td>object</td>
<td>显示对话框弹窗选项见下</td>
</tr>
</tbody>
</table>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  title: '', // String. 弹窗标题。</span><br><span class="line">  subTitle: '', // String (可选)。弹窗的副标题。</span><br><span class="line">  template: '', // String (可选)。放在弹窗body内的html模板。</span><br><span class="line">  templateUrl: '', // String (可选)。放在弹窗body内的一个html模板的URL。</span><br><span class="line">  cancelText: '', // String (默认: 'Cancel')。一个取消按钮的文字。</span><br><span class="line">  cancelType: '', // String (默认: 'button-default')。取消按钮的类型。</span><br><span class="line">  okText: '', // String (默认: 'OK')。OK按钮的文字。</span><br><span class="line">  okType: '', // String (默认: 'button-positive')。OK按钮的类型。</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>返回: object 当关闭对话框时，处理的一个promise。当弹窗关闭时，处理的一个 promise。有一个额外的关闭函数，可以被带有任何给定的值的关闭程序调用。<br>prompt(可选)<br>显示一个简单的提示弹窗，带有一个input， OK 按钮，和取消按钮。如果用户点击OK，就设置promise的值，如果用户点击取消，则值为未定义。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ionicPopup.prompt(&#123;</span><br><span class="line">   title: <span class="string">'Password Check'</span>,</span><br><span class="line">   template: <span class="string">'Enter your secret password'</span>,</span><br><span class="line">   inputType: <span class="string">'password'</span>,</span><br><span class="line">   inputPlaceholder: <span class="string">'Your password'</span></span><br><span class="line"> &#125;).then(<span class="function"><span class="keyword">function</span>(<span class="params">res</span>) </span>&#123;</span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">'Your password is'</span>, res);</span><br><span class="line"> &#125;);</span><br></pre></td></tr></table></figure></p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>
<td>object</td>
<td>显示对话框弹窗选项见下</td>
</tr>
</tbody>
</table>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  title: '', // String. 弹窗的标题。</span><br><span class="line">  subTitle: '', // String (可选)。弹窗的副标题。</span><br><span class="line">  template: '', // String (可选)。放在弹窗body内的html模板。</span><br><span class="line">  templateUrl: '', // String (可选)。放在弹窗body内的html模板的URL。</span><br><span class="line">  inputType: // String (默认: 'text')。input的类型。</span><br><span class="line">  inputPlaceholder: // String (默认: '')。input的 placeholder。</span><br><span class="line">  cancelText: // String (默认: 'Cancel')。取消按钮的文字。</span><br><span class="line">  cancelType: // String (默认: 'button-default')。取消按钮的类型。</span><br><span class="line">  okText: // String (默认: 'OK')。OK按钮的文字。</span><br><span class="line">  okType: // String (默认: 'button-positive')。OK按钮的类型。</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>返回: object 当关闭对话框时，处理的一个promise。当弹窗关闭时，处理的一个 promise。有一个额外的关闭函数，可以被带有任何给定的值的关闭程序调用。</p>
<h3 id="平台-ionicPlatform"><a href="#平台-ionicPlatform" class="headerlink" title="平台$ionicPlatform"></a>平台$ionicPlatform</h3><p>一个angular抽象的ionic.Platform。</p>
<p>用来检测当前的平台，以及诸如在PhoneGap/Cordova中覆盖Android后退按钮。<br>方法<br>onHardwareBackButton(callback)<br>一些平台有硬件的后退按钮，因此可以用这种方法绑定到它。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>callback</td>
<td>function</td>
<td>当该事件发生时，触发回调函数。</td>
</tr>
</tbody>
</table>
<p>offHardwareBackButton(callback)<br>移除一个后退按钮的监听事件。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>callback</td>
<td>function</td>
<td>最初绑定的监视器函数。</td>
</tr>
</tbody>
</table>
<p>registerBackButtonAction(callback, priority, [actionId])<br>注册一个硬件后退按钮动作。当点击按钮时，只有一个动作会执行，因此该方法决定了注册的后退按钮动作具有最高的优先级。</p>
<p>例如，如果一个动作表已经显示，后退按钮应该关闭这个动作表，但是它不应该还能返回一个页面视图或关闭一个打开的模型。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>callback</td>
<td>function</td>
<td>当点击返回按钮时触发，如果该监视器具有最高的优先级。</td>
</tr>
<tr>
<td>priority</td>
<td>number</td>
<td>仅最高优先级的会执行。</td>
</tr>
<tr>
<td>actionId(可选)</td>
<td>*</td>
<td>该id指定这个动作。默认：一个随机且唯一的id。</td>
</tr>
</tbody>
</table>
<p>返回: function 一个被触发的函数，将会注销该后退按钮动作。<br>ready([callback])<br>一旦设备就绪，则触发一个回调函数，或如果该设备已经就绪，则立即调用。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>callback</td>
<td>function=</td>
<td>触发的函数。</td>
</tr>
</tbody>
</table>
<p>返回: promise 当设备就绪后，就会解决一个 promise。</p>
<h3 id="ionic-Platform工具"><a href="#ionic-Platform工具" class="headerlink" title="ionic.Platform工具"></a>ionic.Platform工具</h3><p>方法<br>ready(callback)<br>设备就绪后触发一个回调函数，或如果设备已经就绪理解触发。该方法可以随处运行而无需通过任何附加方法封装。当一个app包含一个web视图（Cordova），当设备就绪后它将会触发回调函数。如果该app包含一个web浏览器，它会在window.load之后触发回调。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>callback</td>
<td>function</td>
<td>调用的函数</td>
</tr>
</tbody>
</table>
<p>device()<br>返回当前设备（通过cordova提供）。</p>
<p>返回: 对象设备对象。<br>isWebView()<br>返回: boolean验证我们是否附带web视图运行（比如Cordova）。<br>isIPad()<br>返回: boolean 是否在iPad上运行。<br>isIOS()<br>返回: boolean 是否在iOS上运行。<br>isAndroid()<br>返回: boolean 是否在Android上运行。<br>isWindowsPhone()<br>返回: boolean 是否在Windows手机上运行。<br>platform()<br>返回: string 当前平台的名字。<br>version()<br>返回: string 当前设备平台的版本。<br>exitApp()<br>退出app。<br>showStatusBar(shouldShow)<br>显示或隐藏设备状态栏（用Cordova）。<br>fullScreen([showFullScreen], [showStatusBar])<br>设置app是否全屏（用Cordova）。</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>详情</th>
</tr>
</thead>
<tbody>
<tr>
<td>showFullScreen(可选)</td>
<td>boolean</td>
<td>是否设置app全屏。默认为true。</td>
</tr>
<tr>
<td>showStatusBar(可选)</td>
<td>boolean</td>
<td>是否显示设备状态栏。默认为false。</td>
</tr>
</tbody>
</table>
<p>属性<br>boolean isReady<br>设备是否就绪。<br>boolean isFullScreen<br>设备是否全屏。<br>Array(string) platforms<br>一个所有平台的数组。<br>string grade<br>当前平台是什么级别的。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/总结/" rel="tag"># 总结</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/12/18/first/" rel="next" title="jQuery原理深究">
                <i class="fa fa-chevron-left"></i> jQuery原理深究
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/12/25/second/" rel="prev" title="ionic总结二">
                ionic总结二 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div id="hypercomments_widget"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image" src="/uploads/avatar.jpg" alt="腊月的季节">
          <p class="site-author-name" itemprop="name">腊月的季节</p>
          <p class="site-description motion-element" itemprop="description">腊月的季节的个人博客</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">160</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">72</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              我的其他足迹
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.csdn.net/qq_33433029" title="CSDN博客" target="_blank">CSDN博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://github.com/youandme66" title="GitHub" target="_blank">GitHub</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/767025e0c4df/timeline" title="我的简书" target="_blank">我的简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.zhihu.com/people/liu-zhi-hao-85-39/activities" title="我的知乎" target="_blank">我的知乎</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#ion-nav-view加载"><span class="nav-number">1.</span> <span class="nav-text">ion-nav-view加载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ion-header-bar添加一个header栏"><span class="nav-number">2.</span> <span class="nav-text">ion-header-bar添加一个header栏</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ion-footbar-bar添加页脚"><span class="nav-number">3.</span> <span class="nav-text">ion-footbar-bar添加页脚</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#选项卡"><span class="nav-number">4.</span> <span class="nav-text">选项卡</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#侧栏菜单"><span class="nav-number">5.</span> <span class="nav-text">侧栏菜单</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#弹出窗口"><span class="nav-number">6.</span> <span class="nav-text">弹出窗口</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#平台-ionicPlatform"><span class="nav-number">7.</span> <span class="nav-text">平台$ionicPlatform</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ionic-Platform工具"><span class="nav-number">8.</span> <span class="nav-text">ionic.Platform工具</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">
  
  &copy;  2016 - 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">腊月的季节</span>
</div>


<div class="powered-by">
   <a class="theme-link" href="http://www.jianshu.com/users/767025e0c4df/timeline">我的简书</a> 
</div>

<div class="theme-info">
  链接 -
  <a class="theme-link" href="https://www.zhihu.com/people/liu-zhi-hao-85-39/activities">
    我的知乎
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>


  



  




	

		<script type="text/javascript">
		_hcwp = window._hcwp || [];

		_hcwp.push({widget:"Bloggerstream", widget_id: 93245, selector:".hc-comment-count", label: "{\%COUNT%\}" });

		
		_hcwp.push({widget:"Stream", widget_id: 93245, xid: "2016/12/25/first/"});
		

		(function() {
		if("HC_LOAD_INIT" in window)return;
		HC_LOAD_INIT = true;
		var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
		var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
		hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/93245/"+lang+"/widget.js";
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(hcc, s.nextSibling);
		})();
		</script>

	





  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("EAvSG3QtXW1dqzq5WQ5CjH7S-gzGzoHsz", "2aiWv7vIfVY4CjKc49aPBHFX");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

</body>
</html>
